﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ResxTranslationProvider.cs" company="Concept Architecture">
//   (c) 2010 Muhammad Umer Farooq
// </copyright>
// <summary>
//   Defines the <seealso cref="ResxTranslationProvider" /> type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Hisaab.Client.Common.Translation
{
    using System.Collections.Generic;
    using System.Globalization;
    using System.Reflection;
    using System.Resources;

    /// <summary>
    /// Defines the <seealso cref="ResxTranslationProvider"/> type.
    /// </summary>
    public class ResxTranslationProvider : ITranslationProvider
    {
        #region Private Members

        /// <summary>
        /// Member variable _resourceManager
        /// </summary>
        private readonly ResourceManager _resourceManager;

        #endregion Private Members

        #region Construction

        /// <summary>
        /// Initializes a new instance of the <see cref="ResxTranslationProvider"/> class.
        /// </summary>
        /// <param name="baseName">Name of the base.</param>
        /// <param name="assembly">The assembly.</param>
        public ResxTranslationProvider(string baseName, Assembly assembly)
        {
            _resourceManager = new ResourceManager(baseName, assembly);
        }

        #endregion Construction

        #region ITranslationProvider Members

        /// <summary>
        /// Gets the available languages.
        /// </summary>
        /// <value>
        /// The available languages.
        /// </value>
        public IEnumerable<CultureInfo> Languages
        {
            get
            {
                yield return new CultureInfo("de");
                yield return new CultureInfo("en");
            }
        }

        #endregion ITranslationProvider Members

        #region ITranslationProvider Members

        /// <summary>
        /// Translates the specified key.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns>Translated object</returns>
        public object Translate(string key)
        {
            return _resourceManager.GetString(key);
        }

        #endregion ITranslationProvider Members
    }
}